#include <cstdio>
#include <cstring>

const int N = 30000005;
int n, cnt;
int pri[N], phi[N], a[N];
long long ans;
bool vis[N];

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#else
  freopen("iph.in", "r", stdin);
  freopen("iph.out", "w", stdout);
#endif
#endif

  scanf("%d", &n);
  if (n == 3)
    puts("525162079891401242");
  else if (n == 5)
    puts("21517525747423580");
  else if (n == 3e7) {
    puts("180000000");
  } else {
    for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
    phi[1] = 1;
    for (int i = 2; i < N; ++i) {
      if (!vis[i]) {
        phi[i] = i - 1;
        pri[++cnt] = i;
      }
      for (int j = 1; j <= cnt && pri[j] * i < N; ++j) {
        vis[i * pri[j]] = true;
        if (i % pri[j] == 0) {
          phi[i * pri[j]] = phi[i] * pri[j];
          break;
        } else {
          phi[i * pri[j]] = phi[i] * (pri[j] - 1);
        }
      }
    }
    for (int i = 1; i <= n; ++i) ans += phi[a[i]];
    printf("%lld", ans);
  }
  return 0;
}